package com.hottop.system.service.impl;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hottop.system.mapper.TBaiduhotMapper;
import com.hottop.system.domain.TBaiduhot;
import com.hottop.system.service.ITBaiduhotService;

/**
 * 百度热搜Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-02-19
 */
@Service
public class TBaiduhotServiceImpl implements ITBaiduhotService 
{
    @Autowired
    private TBaiduhotMapper tBaiduhotMapper;

    /**
     * 查询百度热搜
     * 
     * @param id 百度热搜主键
     * @return 百度热搜
     */
    @Override
    public TBaiduhot selectTBaiduhotById(Long id)
    {
        return tBaiduhotMapper.selectTBaiduhotById(id);
    }

    /**
     * 查询百度热搜列表
     * 
     * @param tBaiduhot 百度热搜
     * @return 百度热搜
     */
    @Override
    public List<TBaiduhot> selectTBaiduhotList(TBaiduhot tBaiduhot)
    {
        return tBaiduhotMapper.selectTBaiduhotList(tBaiduhot);
    }

    /**
     * 新增百度热搜
     * 
     * @param tBaiduhot 百度热搜
     * @return 结果
     */
    @Override
    public int insertTBaiduhot(TBaiduhot tBaiduhot)
    {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//根据自己情况
        Date date=new Date();
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.MINUTE,0);  //分
        cal.set(Calendar.SECOND, 0);
        tBaiduhot.setMindate(date);
        return tBaiduhotMapper.insertTBaiduhot(tBaiduhot);
    }

    /**
     * 修改百度热搜
     * 
     * @param tBaiduhot 百度热搜
     * @return 结果
     */
    @Override
    public int updateTBaiduhot(TBaiduhot tBaiduhot)
    {
        return tBaiduhotMapper.updateTBaiduhot(tBaiduhot);
    }

    /**
     * 批量删除百度热搜
     * 
     * @param ids 需要删除的百度热搜主键
     * @return 结果
     */
    @Override
    public int deleteTBaiduhotByIds(Long[] ids)
    {
        return tBaiduhotMapper.deleteTBaiduhotByIds(ids);
    }

    /**
     * 删除百度热搜信息
     * 
     * @param id 百度热搜主键
     * @return 结果
     */
    @Override
    public int deleteTBaiduhotById(Long id)
    {
        return tBaiduhotMapper.deleteTBaiduhotById(id);
    }

    /**
     * 获取热搜总数
     *
     * @return 结果
     */
    @Override
    public int getCount() {
        return tBaiduhotMapper.getCount();
    }

    /**
     * 获取热搜新增总数
     *
     * @return 结果
     */
    @Override
    public int getYesterdayAddCount() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String dateNowStr = sdf.format(new Date());
        return tBaiduhotMapper.getYesterdayAddCount(dateNowStr);
    }
}
